/*    */ package com.yizhilu.os.image.util;
/*    */ 
/*    */ import java.io.BufferedReader;
/*    */ import java.io.InputStream;
/*    */ import java.io.InputStreamReader;
/*    */ import java.io.OutputStream;
/*    */ import java.net.HttpURLConnection;
/*    */ import java.net.URL;
/*    */ import java.util.Iterator;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ import org.springframework.web.bind.annotation.RequestMethod;
/*    */ 
/*    */ public class HttpUtils
/*    */ {
/*    */   public static String sendHttp(String urls, Map<String, String> param)
/*    */     throws Exception
/*    */   {
/* 17 */     URL url = new URL(urls);
/* 18 */     HttpURLConnection http = (HttpURLConnection)url.openConnection();
/* 19 */     http.setRequestMethod(RequestMethod.POST.toString());
/* 20 */     http.setRequestProperty("Charset", "utf-8");
/* 21 */     http.setDoOutput(true);
/*    */ 
/* 23 */     if ((param != null) && (param.size() > 0)) {
/* 24 */       StringBuffer params = new StringBuffer();
/* 25 */       Set paramName = param.keySet();
/* 26 */       Iterator it = paramName.iterator();
/* 27 */       while (it.hasNext()) {
/* 28 */         String name = (String)it.next();
/* 29 */         String value = (String)param.get(name);
/* 30 */         params.append(name + "=" + value + "&");
/*    */       }
/* 32 */       byte[] bypes = params.toString().getBytes();
/* 33 */       http.getOutputStream().write(bypes);
/*    */     }
/*    */ 
/* 37 */     InputStream inStream = http.getInputStream();
/*    */ 
/* 39 */     BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
/* 40 */     String line = "";
/* 41 */     String result = "";
/* 42 */     while (null != (line = br.readLine())) {
/* 43 */       result = result + line;
/*    */     }
/* 45 */     return result;
/*    */   }
/*    */ }

/* Location:           F:\work\公司\质量学院\ducumentQIN\项目更新\web\20171122\
 * Qualified Name:     com.yizhilu.os.image.util.HttpUtils
 * JD-Core Version:    0.6.1
 */